﻿<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<body>	
		<f:view>
			<h:form id="form1">
				<rich:dataTable id="tbl_kisiler" width="500" rows="10" var="kisi"
					value="#{kisiBean.kisiler}" rowKeyVar="satir">
					<f:facet name="header">
						<h:panelGroup>
							<h:outputText value="Kişiler" />
							<a4j:commandLink ajaxSingle="true" id="yenilink" action="#{kisiBean.mevcutKisiTemizle}"
								oncomplete="#{rich:component('yeniPanel')}.show()">
								<h:graphicImage value="/imaj/ikon/yeni.gif" style="border:0" />
							</a4j:commandLink>
						</h:panelGroup>
					</f:facet>
					<rich:column width="200">
						<f:facet name="header">
							<h:outputText value="Ad" />
						</f:facet>
						<h:outputText value="#{kisi.ad}" />
					</rich:column>
					<rich:column width="250">
						<f:facet name="header">
							<h:outputText value="Soyad" />
						</f:facet>
						<h:outputText value="#{kisi.soyad}" />
					</rich:column>
					<rich:column width="50">
						<f:facet name="header">
							<h:outputText value="İşlem" />
						</f:facet>
						<a4j:commandLink ajaxSingle="true" id="guncellelink"
							oncomplete="#{rich:component('guncellePanel')}.show()">
							<h:graphicImage value="/imaj/ikon/guncelle.gif" style="border:0" />
							<f:setPropertyActionListener value="#{kisi}" target="#{kisiBean.mevcutKisi}" />
						</a4j:commandLink>
						<rich:toolTip for="guncellelink" value="Güncelle" />
						<a4j:commandLink ajaxSingle="true" id="sillink"
							oncomplete="#{rich:component('silPanel')}.show()">
							<h:graphicImage value="/imaj/ikon/sil.gif" style="border:0" />
							<f:setPropertyActionListener value="#{kisi}" target="#{kisiBean.mevcutKisi}" />
						</a4j:commandLink>
						<rich:toolTip for="sillink" value="Sil" />
					</rich:column>
					<f:facet name="footer">
						<rich:datascroller for="tbl_kisiler" maxPages="15"	reRender="tbl_kisiler" />
					</f:facet>
				</rich:dataTable>
			</h:form>
			
			<rich:modalPanel id="yeniPanel" autosized="true" width="450">
				<f:facet name="header">
					<h:outputText value="Kişi Ekle" />
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/imaj/ikon/kapat.gif" id="saklalink" />
						<rich:componentControl for="yeniPanel" attachTo="saklalink"
							operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:form>
					<rich:messages style="color:red;" />
					<h:panelGrid columns="1">
						<a4j:outputPanel ajaxRendered="true">
							<h:panelGrid columns="2">
								<h:outputText value="Ad" />
								<h:inputText value="#{kisiBean.mevcutKisi.ad}" />
								<h:outputText value="Soyad" />
								<h:inputText value="#{kisiBean.mevcutKisi.soyad}" />
							</h:panelGrid>
						</a4j:outputPanel>		
						<h:panelGrid columns="2">
							<a4j:commandButton value="Ekle" reRender="tbl_kisiler, durum" action="#{kisiBean.ekle}"
								oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('yeniPanel')}.hide();" />
							<a4j:commandButton value="İptal"
								onclick="#{rich:component('yeniPanel')}.hide(); return false;" />
						</h:panelGrid>							
					</h:panelGrid>
				</h:form>		
			</rich:modalPanel>				
		
			<rich:modalPanel id="guncellePanel" autosized="true" width="450">
				<f:facet name="header">
					<h:outputText value="Kişi Güncelle" />
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/imaj/ikon/kapat.gif" id="saklalink2" />
						<rich:componentControl for="guncellePanel" attachTo="saklalink2"
							operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:form>
					<rich:messages style="color:red;" />
					<h:panelGrid columns="1">
						<a4j:outputPanel ajaxRendered="true">
							<h:panelGrid columns="2">
								<h:outputText value="Ad" />
								<h:inputText value="#{kisiBean.mevcutKisi.ad}" />
								<h:outputText value="Soyad" />
								<h:inputText value="#{kisiBean.mevcutKisi.soyad}" />
							</h:panelGrid>
						</a4j:outputPanel>		
						<h:panelGrid columns="2">						
							<a4j:commandButton value="Güncelle" reRender="tbl_kisiler, durum" action="#{kisiBean.guncelle}"
								oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('guncellePanel')}.hide();" />
							<a4j:commandButton value="İptal"
								onclick="#{rich:component('guncellePanel')}.hide(); return false;" />
						</h:panelGrid>								
					</h:panelGrid>
				</h:form>
			</rich:modalPanel>
			
			<rich:modalPanel id="silPanel" autosized="true" width="200">
				<f:facet name="header">
					<h:outputText value="Kişi listeden silinsin mi?"
						style="padding-right:15px;" />
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/imaj/ikon/kapat.gif" id="saklalink3" />
						<rich:componentControl for="silPanel" attachTo="saklalink3"
							operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:form>
					<h:panelGrid columns="2">				
						<a4j:commandButton value="Sil" action="#{kisiBean.sil}"
							ajaxSingle="true" oncomplete="#{rich:component('silPanel')}.hide();"
							reRender="tbl_kisiler, durum" />
						<a4j:commandButton value="İptal"
							onclick="#{rich:component('silPanel')}.hide(); return false;" />
					</h:panelGrid>	
				</h:form>
			</rich:modalPanel>
			
			<a4j:status id="durum" onstart="#{rich:component('bekle')}.show()"
				onstop="#{rich:component('bekle')}.hide()" />
				
			<rich:modalPanel id="bekle" autosized="true" width="200" height="120"
				moveable="false" resizeable="false">
				<f:facet name="header">
					<h:outputText value="İşleniyor" />
				</f:facet>
				<h:outputText value="Lütfen Bekleyin..." />
			</rich:modalPanel>			
		</f:view>		
	</body>
</html>